package net.yb.diary.controller;

import lombok.RequiredArgsConstructor;
import net.yb.diary.dto.LoginDTO;
import net.yb.diary.entity.User;
import net.yb.diary.service.UserService;
import net.yb.diary.vo.AjaxResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户 控制器
 */
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;

    @PostMapping("/login")
    public AjaxResult login(@RequestBody LoginDTO loginDTO){
        User user = userService.login(loginDTO);
        return AjaxResult.success(user);
    }

}
